package com.yic.module.mes.dal.mysql.process;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.mes.dal.dataobject.process.ProcessDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.mes.controller.admin.process.vo.*;

/**
 * 工艺信息 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ProcessMapper extends BaseMapperX<ProcessDO> {

    default PageResult<ProcessDO> selectPage(ProcessPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProcessDO>()
                .likeIfPresent(ProcessDO::getName, reqVO.getName())
                .eqIfPresent(ProcessDO::getCode, reqVO.getCode())
                .eqIfPresent(ProcessDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ProcessDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ProcessDO::getCenterId, reqVO.getCenterId())
                .orderByDesc(ProcessDO::getId));
    }

    default List<ProcessDO> selectList(ProcessExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProcessDO>()
                .likeIfPresent(ProcessDO::getName, reqVO.getName())
                .eqIfPresent(ProcessDO::getCode, reqVO.getCode())
                .eqIfPresent(ProcessDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ProcessDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ProcessDO::getCenterId, reqVO.getCenterId())
                .orderByDesc(ProcessDO::getId));
    }

    default ProcessDO selectByName(String name) {
        return selectOne(new LambdaQueryWrapperX<ProcessDO>()
                .eq(ProcessDO::getName, name));
    }

    default ProcessDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<ProcessDO>()
                .eq(ProcessDO::getCode, code));
    }

    default List<ProcessDO> selectList(ProcessPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProcessDO>()
                .likeIfPresent(ProcessDO::getName, reqVO.getName())
                .eqIfPresent(ProcessDO::getCode, reqVO.getCode())
                .eqIfPresent(ProcessDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ProcessDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ProcessDO::getCenterId, reqVO.getCenterId())
                .orderByDesc(ProcessDO::getId));
    }
}
